<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>注册 - 锐聘网</title>
<link href="css/base.css" type="text/css" rel="stylesheet" />
<link href="css/register.css" type="text/css" rel="stylesheet" />
<meta content="大学生求职,大学生就业,大学生招聘,IT人才,IT人才招聘,大学生名企招聘,,大学生找工作,IT名企招聘，IT行业招聘，IT企业快速入职" name="keywords">
<meta content="锐聘专注于为企业提供高效的人力资源解决方案，同时面向IT类技术人才推出快速一站式免费就业服务。秉承QST青软实训人才服务理念，为数千家企业量身定做个性化、全程化的人才培养体系，同时帮助中高级人才铺设成功之路，为人才和企业架设起沟通之桥。" name="description">
  <style>
    #errorMsg{
      display: none;
      font-size: 15px;
      font-weight: 700;
      color: #cd0a0a;
      width: 100px;
      height: 32px;
      margin-left: 90px;
    }
   #yZM{
     display: none;
      font-size: 15px;
      font-weight: 700;
      color: #cd0a0a;
      width: 100px;
      height: 32px;
      margin-left: 90px;
    }
  </style>
</head>

<body>
<iframe src="top.jsp" width="100%" height="100" scrolling="no" frameborder="0" ></iframe>
<div class="content">
  <div class="page_name">注册</div>
  <div class="login_content">
    <div class="login_l">
      <div class="span1">
        <label class="tn-form-label">邮箱：</label>
        <input  class="tn-textbox" type="text" name="applicant_email">
        <span id="errorMsg" >用户名已存在</span>
      </div>
      <div class="span1">
        <label class="tn-form-label">密码：</label>
        <input class="tn-textbox"  type="password" name="applicant_pwd">
        <input type="hidden" name="register_time">
      </div>
      <div class="span1">
        <label class="tn-form-label" >验证码：</label>
        <input class="tn-textbox-long"  type="text" name = "checkCode">
        <span> <img src="/itoffer/checkCodeServlet" title="点击换一换" id = "checkCodeImg"> <a href="javascript:;" id="changeImg" >看不清?</a> </span>
        <p style="height: 30px"><span id="yZM" >验证码错误</span></p>
      </div>
      <div class="tn-form-row-button">
        <div class="span1">
          <input name="register" type="submit" class="tn-button-text" value="立即注册">
          <p class="it-register-text">
            <input  name="" id="" class="tn-checkbox" value="true" checked="checked" type="checkbox">
            <label > 同意本站服务条款</label>
            <a href="javascript:;">查看</a> </p>
        </div>
      </div>
      <div class="clear"></div>
    </div>
    <div class="register_r">
      <p align="center"> <b>还没有帐号？</b><a  href="register.html">10秒钟快速注册</a></p>
    
      <div><img src="images/reg_pic.jpg"></div>
    
      <div class="clear"></div>
    </div>
    <div class="clear"></div>
  </div>
</div>
<iframe src="foot.jsp" width="100%" height="150" scrolling="no" frameborder="0" ></iframe>
<script src="js/axios-0.18.0.js"></script>
<script>
  //补0
  function repair(i){
    if (i >= 0 && i <= 9) {
      return "0" + i;
    } else {
      return i;
    }
  }
  //日期函数
  function getCurrentTime() {
    var date = new Date();//当前时间
    var year = date.getFullYear() //返回指定日期的年份
    var month = repair(date.getMonth() + 1);//月
    var day = repair(date.getDate());//日
    var hour = repair(date.getHours());//时
    var minute = repair(date.getMinutes());//分
    var second = repair(date.getSeconds());//秒

    //当前时间
    var curTime = year + "-" + month + "-" + day
            + " " + hour + ":" + minute + ":" + second;
    return curTime;
  }

  //获取表单中隐藏元素
  let _register_time = document.getElementsByName("register_time")[0];

  //console.log(register_time.value)

  //获取表单对象
  let _applicant_email = document.getElementsByName("applicant_email")[0];
  let _applicant_pwd = document.getElementsByName("applicant_pwd")[0];
  let _checkCode = document.getElementsByName("checkCode")[0];
  //获取注册按钮对象
  let register = document.getElementsByName("register")[0];

  //获取验证码提示对象
  var yZM = document.getElementById("yZM");
  //console.log(yZM)
  //定义参数
  let applicant_email;
  let applicant_pwd;
  let register_time;
  let checkCode;

  //注册按钮点击事件
  register.onclick = function (){
    //将当前时间赋值给隐藏的表单
    _register_time.value = getCurrentTime();
    //传参数赋值
    applicant_email = _applicant_email.value;
    applicant_pwd = _applicant_pwd.value;
    register_time = _register_time.value;
    checkCode = _checkCode.value;
    axios({
      method:"post",
      url:"http://localhost:8080/itoffer/registerServlet?",
      params:{
        applicant_email:applicant_email,
        applicant_pwd:applicant_pwd,
        register_time:register_time,
        checkCode:checkCode,
      }
    }).then(function (resp){
      console.log(resp.data);
        if(resp.data == "yanError") {
          yZM.style.display = "block";
        }
      if(resp.data=="success"){
        alert("注册成功，将跳转到登录界面，请登录您的账号")
        window.location.href = "http://localhost:8080/itoffer/login.html"
      }

    })
  }

  //邮箱框失去焦点事件进行账号查重
  _applicant_email.onblur = function (){
    //alert("失去焦点")
    //传参数赋值
    applicant_email = _applicant_email.value;
    //console.log(applicant_email)
    axios({
      method: "get",
      url: "http://localhost:8080/itoffer/selectByEmailServlet?applicant_email="+applicant_email
    }).then(function (resp){
      console.log(resp.data)
      if(resp.data=="exist"){
        errorMsg.style.display = "block";
      }else if(resp.data =="noExist"){
        errorMsg.style.display = "none";
      }
    })

  }


  //点击文字切换验证码
  document.getElementById("changeImg").onclick = function (){
      document.getElementById("checkCodeImg").src ="/itoffer/checkCodeServlet?"+new Date().getMilliseconds();
  }
  document.getElementById("checkCodeImg").onclick = function (){
    this.src = "/itoffer/checkCodeServlet?"+new Date().getMilliseconds();
  }

</script>
</body>
</html>
